package com.njqy.ticket.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.njqy.ticket.util.CommonUtil;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Component
public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", CommonUtil.getTime(), metaObject);
        this.setFieldValByName("updateTime", CommonUtil.getTime(), metaObject);
        this.setFieldValByName("createBy", CommonUtil.getUserName(), metaObject);
        this.setFieldValByName("updateBy", CommonUtil.getUserName(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", CommonUtil.getTime(), metaObject);
        this.setFieldValByName("updateBy", CommonUtil.getUserName(), metaObject);
    }
}
